import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart' hide Action;
import 'package:video_player/video_player.dart';
import 'package:www.znpigai.teacher/global_store/state.dart';

import 'action.dart';
import 'state.dart';

Widget buildView(
    SocialLoginState state, Dispatch dispatch, ViewService viewService) {
  return new Scaffold(
      body: Stack(
    fit: StackFit.expand,
    children: <Widget>[
      // Image.asset("assets/images/photo_guide1.png", fit: BoxFit.fill),
      VideoPlayer(state.controller),
      Opacity(child: Container(color: Colors.black), opacity: 0.5),
      Positioned(
        left: 0,
        right: 0,
        bottom: 20,
        child: Column(children: <Widget>[
          FlatButton(
            padding: EdgeInsets.symmetric(horizontal: 100, vertical: 10),
            textColor: Colors.white,
            child: Text('账号登录'),
            shape: RoundedRectangleBorder(
                side: BorderSide(
                  color: Colors.white,
                  width: 1,
                ),
                borderRadius: BorderRadius.circular(20)),
            onPressed: () {
              dispatch(SocialLoginActionCreator.onLogin());
            },
          ),
          SizedBox(height: 30),
          GlobalState.wxInstalled && false
              ? Column(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    Row(
                      children: <Widget>[
                        Expanded(
                            child: Divider(
                          height: 1,
                          color: Colors.white,
                          indent: 10,
                          endIndent: 10,
                        )),
                        Text(
                          '其他登录方式',
                          style: TextStyle(color: Colors.white, fontSize: 12),
                        ),
                        Expanded(
                            child: Divider(
                          height: 1,
                          color: Colors.white,
                          indent: 10,
                          endIndent: 10,
                        )),
                      ],
                    ),
                    SizedBox(height: 10),
                    IconButton(
                      iconSize: 40,
                      padding: EdgeInsets.all(10),
                      icon: Image.asset("assets/images/weixin_login.png",
                          fit: BoxFit.fill),
                      onPressed: () {
                        dispatch(SocialLoginActionCreator.onWeixin());
                      },
                    ),
                  ],
                )
              : SizedBox(height: 0),
          SizedBox(height: 10),
          RichText(
            text: new TextSpan(
                text: '登录注册表示同意',
                style: TextStyle(color: Colors.white, fontSize: 12),
                children: [
                  TextSpan(
                    text: '《用户协议》',
                    style: TextStyle(color: Colors.blue),
                    recognizer: new TapGestureRecognizer()
                      ..onTap =
                          () => dispatch(SocialLoginActionCreator.onAgree()),
                  ),
                  TextSpan(
                    text: '和',
                  ),
                  TextSpan(
                    text: '《隐私政策》',
                    style: TextStyle(color: Colors.blue),
                    recognizer: new TapGestureRecognizer()
                      ..onTap =
                          () => dispatch(SocialLoginActionCreator.onPrivate()),
                  ),
                ]),
          ),
          SizedBox(height: 30),
        ]),
      )
    ],
  ));
}
